home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / mkmf / mkmf.boot < prev    next >
Encoding:
Text File  |  1991-04-11  |  2.9 KB  |  102 lines

  1. #!/sprite/cmds/csh -f
  2. #
  3. # A script to generate (or regenerate) a source (cmds) directory  Makefile
  4. # from a prototype Makefile.  If ./Makefile.proto exists, use it, else
  5. # use a common prototype.
  6. #
  7. # We assume we were invoked from mkmf, thus we don't need to alter the
  8. # path, and MKMFDIR is in the environment to tell us where to find prototype
  9. # makefiles, etc.
  10. #
  11. # Parameters passed in from mkmf as environment variables:
  12. #
  13. #    DOMACHINES    names of machines we are supposed to run mkmf on
  14. #    MKMFDIR        directory containing prototype makefiles
  15. #    MKMFFLAGS    arguments to all mkmfs run recursively
  16. #    MACHINES    list of machine names (e.g. "sun2 sun3"), for
  17. #            which there are machine-dependent subdirectories
  18. #            (sun2.md, sun3.md) to hold the object files and
  19. #            any machine-specific source files to use when
  20. #            compiling for that machine
  21. #    MAKEFILE    name of makefile to create
  22. #    SUBTYPE        information about what type of command this is:
  23. #            used to figure out where to install things.
  24. #
  25. # Several of these environment variables must be copied to local shell
  26. # variables before use, because shell variables can be used in some places
  27. # where environment variables can't.
  28.  
  29. #
  30. # Argument processing.  (Generalized form, even though just one flag so far.)
  31. #
  32. while ($#argv >= 1)
  33.     if ("$1" == '-x') then
  34.     set echo
  35.     endif
  36.     shift
  37. end
  38.  
  39. set nonomatch
  40. set srcs =(*.[hcsly] *.md/*.[hcslyo])
  41. set mds = (*.md)
  42. set manPages = (*.man)
  43. if ("$mds" == "*.md") then
  44.     set mds = ()
  45. endif
  46. if ("$manPages" == "*.man") then
  47.     set manPages = ()
  48. endif
  49. #
  50. # Check to see if there were any sources.  The first check (size == 2, the
  51. # number of strings that would be there if there were no matches)
  52. # is only necessary because the second check will cause an error if
  53. # srcs contains more than 1024 bytes.  If no sources, then assume that
  54. # this directory contains only a shell script (and eliminate any
  55. # machine-dependent subdirectories that Pmake might have created).
  56. #
  57. if ($#srcs == 2) then
  58.     if ("$srcs" == "*.[hcsly] *.md/*.[hcslyo]") unset srcs
  59. endif
  60. unset nonomatch
  61. if (! $?srcs) then
  62.     echo "No sources, assuming shell script."
  63.     if ("$mds" != "") then
  64.     echo "Deleting extraneous subdirectories $mds."
  65.     rm -rf $mds
  66.     endif
  67.     $MKMFDIR/mkmf.script $*
  68.     exit $status
  69. endif
  70.  
  71. set subtype=$SUBTYPE
  72. set prog=$cwd:t
  73. set machines=($MACHINES)
  74. set domachines = ($DOMACHINES)
  75. set makefile=($MAKEFILE)
  76. set distdir=($DISTDIR)
  77.  
  78. if (-e $makefile.proto) then
  79.     set proto=$makefile.proto
  80. else
  81.     set proto="${MKMFDIR}/Makefile.boot"
  82. endif
  83.  
  84. echo "Generating $makefile for $prog using $proto"
  85.  
  86.  
  87. cat $proto | sed \
  88.     -e "s,@(DATE),`date`,g" \
  89.     -e "s,@(MACHINES),$machines,g" \
  90.     -e "s,@(MAKEFILE),$makefile,g" \
  91.     -e "s,@(MANPAGES),$manPages,g" \
  92.     -e "s,@(NAME),$prog,g" \
  93.     -e "s,@(TEMPLATE),$proto,g" \
  94.     -e "s,@(TYPE),$subtype,g" \
  95.     -e "s,@(DISTDIR),$distdir,g" \
  96.     > $makefile
  97.  
  98. setenv PARENTDIR $cwd
  99. foreach i ($domachines)
  100.     (cd $i.md; mkmf $MKMFFLAGS -f md.mk)
  101. end
  102.